package com.gimi.cloud.bbp.manage.consumer.service.mall.impl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gimi.cloud.bbp.common.enums.ResponseCodeEnum;
import com.gimi.cloud.bbp.common.exception.MsgException;
import com.gimi.cloud.bbp.common.utils.JsonUtil;
import com.gimi.cloud.bbp.common.utils.StringUtil;
import com.gimi.cloud.bbp.common.utils.reqhead.Response;
import com.gimi.cloud.bbp.common.utils.reqhead.Util;
import com.gimi.cloud.bbp.dto.mall.MallMessageDTO;
import com.gimi.cloud.bbp.manage.consumer.feign.MallMessageFeignService;
import com.gimi.cloud.bbp.manage.consumer.service.mall.MallMessageService;

@Service
public class MallMessageServiceImpl implements MallMessageService{

	@Autowired private MallMessageFeignService service;
	
	@Override
	public Response sendMessage(String requestBody, HttpServletRequest request, HttpServletResponse response) {
		MallMessageDTO dto = JsonUtil.jsonToBean(requestBody, MallMessageDTO.class);
		if (dto.getUserIds() == null || dto.getUserIds().length < 1 || StringUtil.isEmpty(dto.getMeContent()) || StringUtil.isEmpty(dto.getMeTitle())) {
			throw new MsgException(ResponseCodeEnum.PARAMETER_ERROR);
		}
		return service.sendMessage(dto);
	}
}
